#!/usr/bin/env python
# coding=utf-8
from flask import Flask
from flask import request

CACHE_FILE = '/out/cache.txt'


app = Flask(__name__)


@app.route('/')
def hello_world():
    return 'Hello World!'


@app.route('/set')
def set_file():
    data = request.args.get("data")

    with open(CACHE_FILE, 'w+') as f:
        f.write(data)
        f.write('\n')

    return 'set ok\n'


@app.route('/get')
def get_file():

    with open(CACHE_FILE, 'r+') as f:
        data = f.read()

    return data


if __name__ == '__main__':
    app.run(debug=True, host="0.0.0.0", port=80)